<?php

namespace App\Http\Controllers\Admin;

use App\Http\Filters\StoreFilter;
use App\Models\Project;
use App\Models\Store;
use Illuminate\Support\Facades\Request;


class StoreController extends Controller
{
    public function store(StoreFilter $filter)
    {
       $data = Store::query()->filter($filter)
            ->orderByDesc('id')
            ->paginate();
       return $this->ok($data);
    }


    public function updateProject(Request $request)
    {
        $storeId = $request->get('store_id', 0);
        $id = $request->get("project_id", 0);
        $project = Project::where('id', $id)->first();
        if (!$project){
            return $this->error("项目不存在");
        }
        Store::where('id', $storeId)->update(['project_id' => $id]);
        return $this->ok();
    }
}
